<template>
    <div>
        <el-collapse class="collapseList" v-model="activeNames" accordion v-if="readyShow">
            <el-collapse-item title="申报信息" name="1">
                <basics :form="basics"></basics>
            </el-collapse-item>
            <el-collapse-item title="不予确认说明" name="2">
                <dismissal :form="dismissal"></dismissal>
            </el-collapse-item>
        </el-collapse>
    </div>
</template>

<script>
    import Basics from 'components/credit/basic/basics'
    import Dismissal from 'components/credit/dismissal.vue'
    import util from 'assets/js/util.js'

    export default {
        data () {
            return {
                activeNames: [],
                readyShow: false,
                showTrailButton: true,
                showDissent: false,
                showRecheckButton: false,
                showTrail: false,
                showRecheck: false,
                showAdjudication: false,
                basics: {
                    declaerFileids: [],
                    temporaryTotal: '',
                    creditNature: '',
                    undecidedTotal: '',
                    basics_form: {
                        creditNature: '0',
                        mainObligor: '',
                        relatedObligor: '',
                        creditType: '0',
                        giveFirst: '0',
                        //guaranteeHas: '',
                        //guaranteeName: '',
                        guaranteeCond: '',
                        guaranteeForm: '0'
                    },
                    basics_item: {
                        declarePrincipal: 0,
                        declareInterest: 0,
                        declareOther: 0,
                        declareTotal: 0,
                        declareNote: '',
                        declareProcess: '',
                    },
                },
                /*dismissal:{
                    dismissalReceiverName: '',
                    dismissalTime: '',
                    dismissalNote: '',
                },*/
                caseId: 0,
                creditorId: 0
            }
        },
        mounted () {
            this.caseId = util.getUrlParam(document.location.href, 'caseId');
            this.creditorId = util.getUrlParam(document.location.href, 'creditorId');

            const _self = this;
            util.ajax({
                url: '/' + this.caseId + '/' + this.creditorId + `/creditInfo/getCreditInfo`,
                params: {creditId: util.getUrlParam(document.location.href, 'creditId')},
                success: function (data) {
                    _self.basics.basics_form.creditType = _self.matchNatureText(data.message.creditType)
                    _self.basics.basics_form.mainObligor = data.message.mainObligor
                    _self.basics.basics_form.type = _self.matchTypeText(data.message.type)
                    _self.basics.basics_form.giveFirst = data.message.giveFirst === 0 ? '放弃' : '不放弃'
                   // _self.basics.basics_form.guaranteeHas = data.message.guaranteeHas === 0 ? '无' : '有'
                   // _self.basics.basics_form.guaranteeHas = data.message.guaranteeHas === 0 ? '无' : '有'
                    _self.basics.basics_form.guaranteeName = data.message.guaranteeName
                    _self.basics.basics_form.guaranteeCond = data.message.guaranteeCond
                    _self.basics.basics_form.guaranteeForm = _self.matchGuaranteeText(data.message.guaranteeForm)

                    _self.basics.basics_item.declarePrincipal = data.message.declarePrincipal
                    _self.basics.basics_item.declareInterest = data.message.declareInterest
                    _self.basics.basics_item.declareOther = data.message.declareOther
                    _self.basics.basics_item.declareTotal = data.message.declareTotal
                    _self.basics.basics_item.declareNote = data.message.declareNote
                    _self.basics.declaerFileids = data.message.declaerFileids

                    //_self.dismissal.dismissalReceiverName = data.message.dismissalReceiverName
                    //_self.dismissal.dismissalTime = util.formatDate(data.message.dismissalTime)
                    //_self.dismissal.dismissalNote = data.message.dismissalNote

                    _self.readyShow = true
                },
            });
        },
        methods: {
            matchNatureText: function (type) {
                let typeText = '';
                switch (type) {
                    case 1:
                        typeText = '金融借贷';
                        break;
                    case 2:
                        typeText = '民间借贷';
                        break;
                    case 3:
                        typeText = '货款';
                        break;
                    case 4:
                        typeText = '其他';
                        break;
                    default:
                        break;
                }
                return typeText;
            },
            matchTypeText: function (type) {
                let typeText = ''
                switch (type) {
                    case 1:
                        typeText = '职工债权'
                        break
                    case 2:
                        typeText = '普通债权'
                        break
                    case 3:
                        typeText = '税收债权'
                        break
                    case 4:
                        typeText = '优先债权'
                        break
                    default:
                        break
                }
                return typeText
            },
            matchGuaranteeText: function (type) {
                let typeText = ''
                switch (type) {
                    case 1:
                        typeText = '其他'
                        break
                    case 2:
                        typeText = '抵押'
                        break
                    case 3:
                        typeText = '质押'
                        break
                    default:
                        break
                }
                return typeText
            },
        },
        components: {Basics, Dismissal},
    }
</script>
